﻿package idv.etrex.display
{
	import flash.display.Graphics;
	
	/**
	 * 用來將flash中的graphics物件轉成IGraphics物件，搭配GraphicsBat使用。
	 * 
 	 * @includeExample Demo.txt
	 */
	public class FlashGraphics implements IGraphics
	{
		private var graphics:Graphics;
		
		/**
		 * 傳入想要包裝的graphics物件
		 * 
		 * @param	g 
		 */
		public function FlashGraphics(g:Graphics){
			this.graphics = g;
		}

		/**
		 * graphics指令
		 */
		public function beginFill(color:uint, alpha:Number = 1.0):void{
			this.graphics.beginFill(color, alpha);
		}
		
		/**
		 * graphics指令
		 */
		public function clear():void {
			this.graphics.clear();
		}
		
		/**
		 * graphics指令
		 */
		public function drawCircle(x:Number, y:Number, radius:Number):void{
			this.graphics.drawCircle(x, y, radius);
		}
		
		/**
		 * graphics指令
		 */
		public function drawEllipse(x:Number, y:Number, width:Number, height:Number):void{
			this.graphics.drawEllipse(x, y, width, height);
		}
		
		/**
		 * graphics指令
		 */
		public function drawRect(x:Number, y:Number, width:Number, height:Number):void{
			this.graphics.drawRect(x, y, width, height);
		}
		
		/**
		 * graphics指令
		 */
		public function drawRoundRect(x:Number, y:Number, width:Number, height:Number, ellipseWidth:Number, ellipseHeight:Number = NaN):void{
			this.graphics.drawRoundRect(x, y, width, height, ellipseWidth, ellipseHeight);
		}
		
		/**
		 * graphics指令
		 */
		public function endFill():void {
			this.graphics.endFill();
		}
		
		/**
		 * graphics指令
		 */
		public function lineStyle(thickness:Number = NaN, color:uint = 0, alpha:Number = 1.0, pixelHinting:Boolean = false, scaleMode:String = "normal", caps:String = null, joints:String = null, miterLimit:Number = 3):void{
			this.graphics.lineStyle(thickness, color, alpha, pixelHinting, scaleMode, caps, joints, miterLimit);
		}
		
		/**
		 * graphics指令
		 */
		public function moveTo(x:Number, y:Number):void {
			this.graphics.moveTo(x, y);
		}
		
		/**
		 * graphics指令
		 */
		public function lineTo(x:Number, y:Number):void{
			this.graphics.lineTo(x, y);
		}
	}
	
}